import { formatGMTDate, toPercent, compareObject } from '../../../../assets/js/util.js'
import echarts from 'echarts'

export default {
    data() {
        return {
            // loading
            loading: true,
            // 默认参数 和 URL
            SRC: '',
            DP: {
                p: '',
                f: ''
            },
            // title
            title: "平台/渠道",
            xlsxTitle: "",
            xlsxTitleQ: "",
            /* 的宽*/
            pageWidth: '100%',
            pickerOptions: {
                shortcuts: [{
                    text: '最近7天',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近15天',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 15);
                        picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近30天',
                    onClick(picker) {
                        const end = new Date();
                        const start = new Date();
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                        picker.$emit('pick', [start, end]);
                    }
                }]
            },
            // 默认选择 全平台
            activeIndex2: '0',
            // 请求参数
            postObj: {
                dstart: '',
                dend: ''
            },
            // 分页一
            page1: {
                /*当前页显示数量*/
                pageSize: 10,
                /*每页显示的数量*/
                pageSizes: [10, 20, 50, 100],
                /*dataTotal表数量*/
                dataTotal: 0,
                /*分页器*/
                currentPage: 1,
            },
            // 分页二
            page2: {
                /*当前页显示数量*/
                pageSize: 10,
                /*每页显示的数量*/
                pageSizes: [10, 20, 50, 100],
                /*dataTotal表数量*/
                dataTotal: 0,
                /*分页器*/
                currentPage: 1,
            },
            // 分页三
            page3: {
                /*当前页显示数量*/
                pageSize: 10,
                /*每页显示的数量*/
                pageSizes: [10, 20, 50, 100],
                /*dataTotal表数量*/
                dataTotal: 0,
                /*分页器*/
                currentPage: 1,
            },
            // 平台请求过来的数据全部
            platformDataList: [],
            date: '',
            tableHeader1: [
                { "prop": "platformId", "label": "平台", 'width': '80', 'fixed': true },
                { "prop": "activeDevice", "label": "激活设备数", 'width': '110', 'fixed': false },
                { "prop": "newDevice", "label": "新增设备数", 'width': '110', 'fixed': false },
                { "prop": "active2NewRadio", "label": "激活新增转化率", 'width': '140', 'fixed': false },
                { "prop": "newUser", "label": "新增账号数", 'width': '110', 'fixed': false },
                { "prop": "activeUserCount", "label": "活跃账号数", 'width': '110', 'fixed': false },
                { "prop": "payCount", "label": "付费金额（" + localStorage.getItem("ZULONGBICURRENCY") + "）", 'width': '150', 'fixed': false },
                { "prop": "payUserCount", "label": "付费账号数", 'width': '110', 'fixed': false },
                { "prop": "newUserPayRatio", "label": "新增账号付费率", 'width': '170', 'fixed': false },
                { "prop": "activePayRadio", "label": "活跃付费率", 'width': '110', 'fixed': false },
                { "prop": "payARPU", "label": "付费ARPU", 'width': '110', 'fixed': false },
                { "prop": "activeARPU", "label": "活跃ARPU", 'width': '110', 'fixed': false },
                { "prop": "avgOnlineTime", "label": "人均在线时长(m)", 'width': '150', 'fixed': false },
                { "prop": "the2Left", "label": "新增帐号次日留存率", 'width': '170', 'fixed': false },
                { "prop": "the3Left", "label": "新增帐号3日留存率", 'width': '170', 'fixed': false },
                { "prop": "the7Left", "label": "新增帐号7日留存率", 'width': '170', 'fixed': false },
                { "prop": "the14Left", "label": "新增帐号14日留存率", 'width': '170', 'fixed': false },
                { "prop": "the30Left", "label": "新增帐号30日留存率", 'width': '170', 'fixed': false },
                { "prop": "the60Left", "label": "新增帐号60日留存率", 'width': '170', 'fixed': false },
                { "prop": "the90Left", "label": "新增帐号90日留存率", 'width': '170', 'fixed': false },
                { "prop": "validatedNewUser", "label": "有效新增用户数", 'width': '170', 'fixed': false },
                { "prop": "loginNewUservalidatedRadio", "label": "登录比新增用户有效率", 'width': '180', 'fixed': false },
                { "prop": "loginRadioAliveUserCount", "label": "登录比留存用户数", 'width': '170', 'fixed': false },
                { "prop": "loginRadio", "label": "一阶登录比", 'width': '120', 'fixed': false },
                { "prop": "loginRadio2", "label": "二阶登录比", 'width': '120', 'fixed': false },
                { "prop": "the1LTV", "label": "1日LTV", 'width': '100', 'fixed': false },
                { "prop": "the3LTV", "label": "3日LTV", 'width': '100', 'fixed': false },
                { "prop": "the7LTV", "label": "7日LTV", 'width': '100', 'fixed': false },
                { "prop": "the14LTV", "label": "14日LTV", 'width': '100', 'fixed': false },
                { "prop": "the30LTV", "label": "30日LTV", 'width': '100', 'fixed': false },
                { "prop": "the60LTV", "label": "60日LTV", 'width': '100', 'fixed': false },
                { "prop": "the90LTV", "label": "90日LTV", 'width': '100', 'fixed': false },
                { "prop": "the120LTV", "label": "120日LTV", 'width': '100', 'fixed': false },
            ],
            tableData1: [],
            tableHeaderAll21: [
                { "prop": "dateStr", "label": "日期", 'width': '120', 'fixed': true },
                { "prop": "activeDevice", "label": "激活设备数", 'width': '140', 'fixed': false },
                { "prop": "newDevice", "label": "新增设备数", 'width': '140', 'fixed': false },
                { "prop": "active2NewRadio", "label": "激活新增转化率", 'width': '160', 'fixed': false },
                { "prop": "newUser", "label": "新增账号数", 'width': '140', 'fixed': false },
                { "prop": "activeUserCountByDay", "label": "活跃账号数", 'width': '140', 'fixed': false },
                { "prop": "payCount", "label": "付费金额（" + localStorage.getItem("ZULONGBICURRENCY") + "）", 'width': '160', 'fixed': false },
                { "prop": "payUserCountByDay", "label": "付费账号数", 'width': '140', 'fixed': false },
                { "prop": "newUserPayRatio", "label": "新增账号付费率", 'width': '170', 'fixed': false },
                { "prop": "activePayRadio", "label": "活跃付费率", 'width': '140', 'fixed': false },
                { "prop": "payARPU", "label": "付费ARPU", 'width': '140', 'fixed': false },
                { "prop": "activeARPU", "label": "活跃ARPU", 'width': '140', 'fixed': false },
                { "prop": "avgOnlineTime", "label": "人均在线时长(m)", 'width': '170', 'fixed': false },
                { "prop": "the2Left", "label": "新增帐号次日留存率", 'width': '190', 'fixed': false },
                { "prop": "the3Left", "label": "新增帐号3日留存率", 'width': '190', 'fixed': false },
                { "prop": "the7Left", "label": "新增帐号7日留存率", 'width': '190', 'fixed': false },
                { "prop": "the14Left", "label": "新增帐号14日留存率", 'width': '190', 'fixed': false },
                { "prop": "the30Left", "label": "新增帐号30日留存率", 'width': '190', 'fixed': false },
                { "prop": "the60Left", "label": "新增帐号60日留存率", 'width': '190', 'fixed': false },
                { "prop": "the90Left", "label": "新增帐号90日留存率", 'width': '190', 'fixed': false },
                { "prop": "validatedNewUser", "label": "有效新增用户数", 'width': '190', 'fixed': false },
                { "prop": "loginNewUservalidatedRadio", "label": "登录比新增用户有效率", 'width': '200', 'fixed': false },
                { "prop": "loginRadioAliveUserCount", "label": "登录比留存用户数", 'width': '200', 'fixed': false },
                { "prop": "loginRadio", "label": "一阶登录比", 'width': '140', 'fixed': false },
                { "prop": "loginRadio2", "label": "二阶登录比", 'width': '140', 'fixed': false },
                { "prop": "the1LTV", "label": "1日LTV", 'width': '120', 'fixed': false },
                { "prop": "the3LTV", "label": "3日LTV", 'width': '120', 'fixed': false },
                { "prop": "the7LTV", "label": "7日LTV", 'width': '120', 'fixed': false },
                { "prop": "the14LTV", "label": "14日LTV", 'width': '120', 'fixed': false },
                { "prop": "the30LTV", "label": "30日LTV", 'width': '120', 'fixed': false },
                { "prop": "the60LTV", "label": "60日LTV", 'width': '120', 'fixed': false },
                { "prop": "the90LTV", "label": "90日LTV", 'width': '120', 'fixed': false },
                { "prop": "the120LTV", "label": "120日LTV", 'width': '120', 'fixed': false },
            ],
            tableData21: [],
            tableDataAll21: [],
            tableHeaderAll22: [
                { "prop": "platformId", "label": "平台", "width": '100', 'fixed': true },
                { "prop": "channelName", "label": "渠道", "width": '140', 'fixed': true },
                { "prop": "activeDevice", "label": "激活设备数", "width": '140', 'fixed': false },
                { "prop": "newDevice", "label": "新增设备数", 'width': '140', 'fixed': false },
                { "prop": "active2NewRadio", "label": "激活新增转化率", 'width': '160', 'fixed': false },
                { "prop": "newUser", "label": "新增账号数", "width": '140', 'fixed': false },
                { "prop": "activeUserCount", "label": "活跃账号数", "width": '140', 'fixed': false },
                { "prop": "payCount", "label": "付费金额（" + localStorage.getItem("ZULONGBICURRENCY") + "）", "width": '160', 'fixed': false },
                { "prop": "payUserCount", "label": "付费账号数", "width": '140', 'fixed': false },
                { "prop": "newUserPayRatio", "label": "新增账号付费率", 'width': '170', 'fixed': false },
                { "prop": "activePayRadio", "label": "活跃付费率", "width": '140', 'fixed': false },
                { "prop": "payARPU", "label": "付费ARPU", "width": '140', 'fixed': false },
                { "prop": "activeARPU", "label": "活跃ARPU", "width": '140', 'fixed': false },
                { "prop": "avgOnlineTime", "label": "人均在线时长(m)", "width": '120', 'fixed': false },
                { "prop": "the2Left", "label": "新增帐号次日留存率", "width": '120', 'fixed': false },
                { "prop": "the3Left", "label": "新增帐号3日留存率", "width": '120', 'fixed': false },
                { "prop": "the7Left", "label": "新增帐号7日留存率", "width": '120', 'fixed': false },
                { "prop": "the14Left", "label": "新增帐号14日留存率", "width": '120', 'fixed': false },
                { "prop": "the30Left", "label": "新增帐号30日留存率", "width": '120', 'fixed': false },
                { "prop": "the60Left", "label": "新增帐号60日留存率", "width": '120', 'fixed': false },
                { "prop": "the60Left", "label": "新增帐号90日留存率", "width": '120', 'fixed': false },
                { "prop": "validatedNewUser", "label": "有效新增用户数", "width": '120', 'fixed': false },
                { "prop": "loginNewUservalidatedRadio", "label": "登录比新增用户有效率", "width": '120', 'fixed': false },
                { "prop": "loginRadioAliveUserCount", "label": "登录比留存用户数", "width": '120', 'fixed': false },
                { "prop": "loginRadio", "label": "一阶登录比", "width": '120', 'fixed': false },
                { "prop": "loginRadio2", "label": "二阶登录比", "width": '120', 'fixed': false },
                { "prop": "the1LTV", "label": "1日LTV", "width": '120', 'fixed': false },
                { "prop": "the3LTV", "label": "3日LTV", "width": '120', 'fixed': false },
                { "prop": "the7LTV", "label": "7日LTV", "width": '120', 'fixed': false },
                { "prop": "the14LTV", "label": "14日LTV", "width": '120', 'fixed': false },
                { "prop": "the30LTV", "label": "30日LTV", "width": '120', 'fixed': false },
                { "prop": "the60LTV", "label": "60日LTV", "width": '120', 'fixed': false },
                { "prop": "the90LTV", "label": "90日LTV", "width": '120', 'fixed': false },
                { "prop": "the120LTV", "label": "120日LTV", "width": '120', 'fixed': false }
            ],
            tableData22: [],
            tableDataAll22: [],
            tableHeaderAll23: [
                { "prop": "dateStr", "label": "日期", "width": '140px', "fixed": true },
                { "prop": "platformId", "label": "平台", "width": '100px', "fixed": true },
                { "prop": "channelName", "label": "渠道", "width": '140px', "fixed": true },
                { "prop": "activeDevice", "label": "激活设备数", "width": '140px', "fixed": false },
                { "prop": "newDevice", "label": "新增设备数", 'width': '140', 'fixed': false },
                { "prop": "active2NewRadio", "label": "激活新增转化率", 'width': '160', 'fixed': false },
                { "prop": "newUser", "label": "新增账号数", "width": '140px', "fixed": false },
                { "prop": "activeUserCountByDay", "label": "活跃账号数", "width": '140px', "fixed": false },
                { "prop": "payCount", "label": "付费金额（" + localStorage.getItem("ZULONGBICURRENCY") + "）", "width": '160px', "fixed": false },
                { "prop": "payUserCountByDay", "label": "付费账号数", "width": '140px', "fixed": false },
                { "prop": "newUserPayRatio", "label": "新增账号付费率", 'width': '170', 'fixed': false },
                { "prop": "activePayRadio", "label": "活跃付费率", "width": '140px', "fixed": false },
                { "prop": "payARPU", "label": "付费ARPU", "width": '140px', "fixed": false },
                { "prop": "activeARPU", "label": "活跃ARPU", "width": '140px', "fixed": false },
                { "prop": "avgOnlineTime", "label": "人均在线时长(m)", "width": '190px', "fixed": false },
                { "prop": "the2Left", "label": "新增帐号次日留存率", "width": '190px', "fixed": false },
                { "prop": "the3Left", "label": "新增帐号3日留存率", "width": '190px', "fixed": false },
                { "prop": "the7Left", "label": "新增帐号7日留存率", "width": '190px', "fixed": false },
                { "prop": "the14Left", "label": "新增帐号14日留存率", "width": '190px', "fixed": false },
                { "prop": "the30Left", "label": "新增帐号30日留存率", "width": '190px', "fixed": false },
                { "prop": "the30Left", "label": "新增帐号60日留存率", "width": '120', 'fixed': false },
                { "prop": "the30Left", "label": "新增帐号90日留存率", "width": '120', 'fixed': false },
                { "prop": "validatedNewUser", "label": "有效新增用户数", "width": '170px', "fixed": false },
                { "prop": "loginNewUservalidatedRadio", "label": "登录比新增用户有效率", "width": '200px', "fixed": false },
                { "prop": "loginRadioAliveUserCount", "label": "登录比留存用户数", "width": '170px', "fixed": false },
                { "prop": "loginRadio", "label": "一阶登录比", "width": '140px', "fixed": false },
                { "prop": "loginRadio2", "label": "二阶登录比", "width": '140px', "fixed": false },
                { "prop": "the1LTV", "label": "1日LTV", "width": '120', 'fixed': false },
                { "prop": "the3LTV", "label": "3日LTV", "width": '120', 'fixed': false },
                { "prop": "the7LTV", "label": "7日LTV", "width": '120', 'fixed': false },
                { "prop": "the14LTV", "label": "14日LTV", "width": '120', 'fixed': false },
                { "prop": "the30LTV", "label": "30日LTV", "width": '120', 'fixed': false },
                { "prop": "the60LTV", "label": "60日LTV", "width": '120', 'fixed': false },
                { "prop": "the90LTV", "label": "90日LTV", "width": '120', 'fixed': false },
                { "prop": "the120LTV", "label": "120日LTV", "width": '120', 'fixed': false }
            ],
            tableData23: [],
            tableDataAll23: [],

            // 渠道的详细数据 安卓
            andChannelDetail: [],
            // 渠道汇总数据:[] 安卓
            andChannelAll: [],
            // 渠道的详细数据 iOS
            iOSChannelDetail: [],
            // 渠道汇总数据:[] 安卓
            iOSChannelAll: [],
            // 安卓数据
            andPlatformDataList: [],
            // iOS数据
            iOSPlatformDataList: [],

            platformDataList2: [],
            detailChannelDisplayDataList: [],
            channelDisplayDataList: [],

            // 排序的前一次点击  是倒序还是正序
            sortYUE: false,
        }
    },
    methods: {
        // 通用 成功 与 失败
        successFun(data) {
            this.$message({
                message: data,
                type: 'success'
            });
        },
        errorFun(data) {
            this.$message.error(data);
        },
        // 表格下载
        excel(tableIndex, sheet) {
            var that = this;
            if (tableIndex == '1') {
                that.xlsxTitle = sheet + "-" + that.postObj.dstart + "到" + that.postObj.dend;
            } else if (tableIndex == 'All21' || tableIndex == 'All22' || tableIndex == 'All23') {
                that.xlsxTitle = sheet + "-" + that.xlsxTitleQ + "-" + that.postObj.dstart + "到" + that.postObj.dend;
            }
            that.downloadExl(that['tableHeader' + tableIndex], that['tableData' + tableIndex], that.xlsxTitle, sheet);
        },
        // 改变表格每行的颜色
        tableRowClassName(row, index) {
            if (index === 0) {
                return 'one-row';
            } else if (index === 1) {
                return 'two-row';
            } else if (index === 2) {
                return 'three-row';
            }
            return '';
        },
        //在线趋势 菜单变换
        handle(key, keyPath) {
            switch (key) {
                case '0':
                    this.activeIndex2 = key;
                    // this.activeChange('0');
                    this.channelMsg(key);
                    break;
                case '2':
                    this.activeIndex2 = key;
                    // this.activeChange('2');
                    this.channelMsg(key);
                    break;
                case '3':
                    this.activeIndex2 = key;
                    // this.activeChange('3');
                    this.channelMsg(key);
                    break;
            }
        },
        //改变平台渠道数据变换
        channelMsg(num) {
            if (num === '0') {
                var obj = this.getPlatformDataList(this.platformDataList, '全平台');
                this.xlsxTitleQ = "全平台";
                this.page1.dataTotal = obj.togglerDatas.length;
                this.tableDataAll21 = this.platIdToName(this.pencent(obj.togglerDatas, 1));
                this.tableControl1();

                this.page2.dataTotal = this.channelDisplayDataList.length;
                this.tableDataAll22 = this.platIdToName(this.channelDisplayDataList);
                this.tableControl2();

                this.page3.dataTotal = this.detailChannelDisplayDataList.length;
                this.tableDataAll23 = this.platIdToName(this.detailChannelDisplayDataList);
                this.tableControl3();
            } else if (num === '2') {
                var obj = this.getPlatformDataList(this.platformDataList, 'iOS');
                this.xlsxTitleQ = "iOS";
                this.page1.dataTotal = obj.togglerDatas.length;
                this.tableDataAll21 = this.platIdToName(this.pencent(obj.togglerDatas, 1));
                this.tableControl1();

                this.page2.dataTotal = this.iOSChannelDetail.length
                this.tableDataAll22 = this.platIdToName(this.iOSChannelDetail);
                this.tableControl2();

                this.page3.dataTotal = this.iOSChannelAll.length;
                this.tableDataAll23 = this.platIdToName(this.iOSChannelAll);
                this.tableControl3();
            } else if (num === '3') {
                var obj = this.getPlatformDataList(this.platformDataList, '安卓');
                this.xlsxTitleQ = "安卓";
                this.page1.dataTotal = obj.togglerDatas.length;
                this.tableDataAll21 = this.platIdToName(this.pencent(obj.togglerDatas, 1));
                this.tableControl1();

                this.page2.dataTotal = this.andChannelDetail.length
                this.tableDataAll22 = this.platIdToName(this.andChannelDetail);
                this.tableControl2();

                this.page3.dataTotal = this.andChannelAll.length;
                this.tableDataAll23 = this.platIdToName(this.andChannelAll);
                this.tableControl3();
            }
        },
        handleSizeChange1(val) {
            this.page1.pageSize = val;
            this.tableControl1();
        },
        handleCurrentChange1(val) {
            this.page1.currentPage = val;
            this.tableControl1();
        },
        handleSizeChange2(val) {
            this.page2.pageSize = val;
            this.tableControl2();
        },
        handleCurrentChange2(val) {
            this.page2.currentPage = val;
            this.tableControl2();
        },
        handleSizeChange3(val) {
            this.page3.pageSize = val;
            this.tableControl3();
        },
        handleCurrentChange3(val) {
            this.page3.currentPage = val;
            this.tableControl3();
        },
        tableControl1() {
            this.tableData21 = this.tableDataAll21.slice((this.page1.currentPage - 1) * this.page1.pageSize, this.page1.currentPage * this.page1.pageSize);
        },
        tableControl2() {
            this.tableData22 = this.tableDataAll22.slice((this.page2.currentPage - 1) * this.page2.pageSize, this.page2.currentPage * this.page2.pageSize);
        },
        tableControl3() {
            this.tableData23 = this.tableDataAll23.slice((this.page3.currentPage - 1) * this.page3.pageSize, this.page3.currentPage * this.page3.pageSize);
        },
        // 时间改变 得到起始时间和结束时间
        dateChange(val) {
            if (val === undefined || val === '') {
                this.errorFun('请选择查看时间！')
            } else {
                var t = val.split(' - ')
                this.postObj.dstart = t[0];
                this.postObj.dend = t[1];
                if (this.tableData1.length !== 0) {
                    this.getData(this.postObj);
                }
            }
        },
        // 将 平台编号0  2  3 变成 名称
        platIdToName(data) {
            for (var i in data) {
                if (data[i]['platformId'] === '0') {
                    data[i]['platformId'] = '全平台';
                } else if (data[i]['platformId'] === '2') {
                    data[i]['platformId'] = 'iOS';
                } else if (data[i]['platformId'] === '3') {
                    data[i]['platformId'] = '安卓';
                } else if (data[i]['platformId'] === '9') {
                    data[i]['platformId'] = '通用';
                }
            }
            return data
        },
        // 变成分数 时间变成ms 1为转换 0 为不转换
        pencent(data, ms) {
            //转换为%比
            var arr = ['newUserPayRatio', 'active2NewRadio', 'activePayRadio', 'the2Left', 'the3Left', 'the7Left', 'the14Left', 'the30Left', 'the60Left', 'the90Left', 'loginNewUservalidatedRadio', 'loginRadio', 'loginRadio2'];
            var arr1 = ['avgOnlineTime'];
            for (var i = 0; i < data.length; i++) {
                if (typeof data[i]["activePayRadio"] === 'string') {
                    return data;
                }
                for (var j in data[i]) {
                    for (var n = 0; n < arr.length; n++) {
                        if (j === arr[n]) {
                            if (data[i][j] == 0 && j != 'newUserPayRatio' && j != 'activePayRadio') { data[i][j] = "" } else { data[i][j] = toPercent(data[i][j]); }
                        } else if (j === arr1[n] && ms == 1) {
                            data[i][j] = Math.round(data[i][j] / 60);
                        }
                    }
                }
            }
            return data
        },
        // 选择页面展示的平台详细数据
        getPlatformDataList(data, plat) {
            if (plat === '0') {
                plat = "全平台";
            } else if (plat === '2') {
                plat = "iOS";
            } else if (plat === '3') {
                plat = "安卓";
            }
            for (var i = 0; i < data.length; i++) {
                for (var j in data[i]) {
                    if (data[i]['platformId'] === plat) {
                        return data[i]
                    }
                }
            }
        },
        cpData1(data) {
            this.andChannelDetail = [];
            this.iOSChannelDetail = [];
            this.channelDisplayDataList = data;
            for (var i = 0; i < data.length; i++) {
                if (data[i]['platformId'] === '安卓') {
                    this.andChannelDetail.push(data[i])
                } else if (data[i]['platformId'] === 'iOS') {
                    this.iOSChannelDetail.push(data[i])
                }
            }
        },
        cpData2(data) {
            this.andChannelAll = [];
            this.iOSChannelAll = [];
            this.detailChannelDisplayDataList = data;
            for (var i = 0; i < data.length; i++) {
                if (data[i]['platformId'] === '安卓') {
                    this.andChannelAll.push(data[i])
                } else if (data[i]['platformId'] === 'iOS') {
                    this.iOSChannelAll.push(data[i])
                }
            }
        },
        // 
        // 获取数据
        getData(data) {
            var that = this;
            that.loading = true;
            var p = new Promise(function(resolve, reject) {
                that.$http.jsonp(`${that.SRC}data/get.do?p=${that.DP.p}&f=${that.DP.f}&a=search`, {
                    params: {
                        'ps': `dstart=${data.dstart}&dend=${data.dend}`
                    }
                }).then(function(res) {
                    resolve(res.body)
                })
            })
            p.then(function(value) {
                that.tableData1 = [];
                var data = JSON.parse(value)
                var d = JSON.parse(data.replace(/\"\{\"/g, '\{\"').replace(/\"\}\"/g, '\"\}'));
                if (parseInt(d["res"]) === 0) {
                    that.loading = false;
                    // 表1
                    that.platformDataList = d.platformDataList;
                    // that.clcikPlats(d.platformDataList);
                    that.tableData1 = that.platIdToName(d.platformDataList);
                    that.pencent(d.platformDataList);
                    // 表2
                    d.platformDataList = that.getPlatformDataList(d.platformDataList, that.activeIndex2);
                    that.page1.dataTotal = d.platformDataList.togglerDatas.length;
                    that.tableDataAll21 = that.platIdToName(d.platformDataList.togglerDatas);
                    that.pencent(d.platformDataList.togglerDatas, 1);
                    that.tableControl1();
                    // that.cpData0(d.platformDataList.togglerDatas)

                    // 表3
                    that.page2.dataTotal = d.channelDisplayDataList.length;
                    that.tableDataAll22 = that.platIdToName(d.channelDisplayDataList);
                    that.pencent(d.channelDisplayDataList);
                    that.tableControl2();
                    that.cpData1(d.channelDisplayDataList);
                    //表4
                    that.page3.dataTotal = d.detailChannelDisplayDataList.length;
                    that.tableDataAll23 = that.platIdToName(d.detailChannelDisplayDataList);
                    that.pencent(d.detailChannelDisplayDataList, 1);
                    that.tableControl3();
                    that.cpData2(d.detailChannelDisplayDataList);

                    that.channelMsg(that.activeIndex2)
                } else {
                    that.getErrorMsg(Number(d.res))
                }
            })
        },
        // 表格排序
        sortChange(column) {
            if (column.prop === null) {
                return;
            } else if (column.order === 'descending') {
                this.tableDataAll21.sort(compareObject(column.prop, false));
            } else { //正序
                this.tableDataAll21.sort(compareObject(column.prop, true));
            }
            this.tableControl1();
        },
        // 表格排序
        sortChange2(column) {
            if (column.prop === null) {
                return;
            } else if (column.order === 'descending') {
                this.tableDataAll22.sort(compareObject(column.prop, false));
            } else { //正序
                this.tableDataAll22.sort(compareObject(column.prop, true));
            }
            this.tableControl2();
        },
        // 表格排序
        // 排序特殊处理  先排序渠道，再排序时间
        comparetime(propertyName, positive) {
            var that = this;
            return function(object1, object2) {
                var value1 = object1[propertyName],
                    value2 = object2[propertyName];
                if (value1 === value2) {
                    var value1 = new Date(object1['dateStr'].replace(/-/g, "/")),
                        value2 = new Date(object2['dateStr'].replace(/-/g, "/"));
                    return that.sortYUE ? value2 - value1 : value1 - value2
                } else {
                    return positive ? value1.localeCompare(value2) : value2.localeCompare(value1);
                }
            }
        },
        sortChange3(column) {
            if (column.prop === null) {
                return;
            } else if (column.prop === 'dateStr') {
                if (column.order === 'descending') {
                    this.sortYUE = true;
                } else { //正序
                    this.sortYUE = false;
                }
            } else if (column.prop === 'channelName') {
                if (column.order === 'descending') {
                    this.tableDataAll23.sort(this.comparetime(column.prop, false));
                } else { //正序
                    this.tableDataAll23.sort(this.comparetime(column.prop, true));
                }
            } else {
                if (column.order === 'descending') {
                    this.tableDataAll23.sort(compareObject(column.prop, false));
                } else { //正序
                    this.tableDataAll23.sort(compareObject(column.prop, true));
                }
            }
            this.tableControl3();
        },
    },
    computed: {
        // xlsx() {
        //     return this.title + '.xlsx'
        // }
    },
    mounted() {
        // 初始化URL
        this.SRC = this.$store.getters.src;
        this.DP.p = localStorage.getItem('ZULONGBIPROJECTID');
        this.DP.f = localStorage.getItem('ZULONGBIPAGEID');
        this.date = [new Date(new Date().getTime() - 16 * 86400000), new Date(new Date().getTime() - 86400000)];
        this.postObj.dstart = formatGMTDate(new Date().getTime() - 86400000 * 16, true);
        this.postObj.dend = formatGMTDate(new Date().getTime() - 86400000, true);
        this.getData(this.postObj);
    }
}